package com.hrhr74.penguinstream.utils;

import lombok.Data;
import com.hrhr74.penguinstream.constant.ResultConstant;

@Data
public class  Result<T>{
    private T data;
    private String msg;
    private String code;

    public static Result ok(String msg){
        Result result = new Result();
        result.setMsg(msg);
        result.setCode(ResultConstant.SuccessCode);
        return result;
    }

    public static Result error(String msg){
        Result result = new Result();
        result.setMsg(msg);
        result.setCode(ResultConstant.ErrorCode);
        return result;
    }

    public static <T> Result<T> ok(T data,String msg){
        Result<T> result = new Result<>();

        result.setData(data);
        result.setCode(ResultConstant.SuccessCode);
        result.setMsg(msg);

        return result;
    }

    public static Result ok(){
        return ok("执行成功!");
    }
}
